﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using com.eforceglobal.crux.views.Controls.Common;
using com.eforceglobal.crux.controllers.Controls.Common;
using com.eforceglobal.crux.views.Enums;

public partial class Controls_Common_ManagedEntityName : System.Web.UI.UserControl, IManagedEntityName
{

    ManagedEntityNameController _ManagedEntityNameController = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        _ManagedEntityNameController = new ManagedEntityNameController(this);
        _ManagedEntityNameController.InitView(IsPostBack);
    }

    #region IManagedEntityName Members

    public int EntityID
    {
        get {return int.Parse(Request.Params["id"].ToString()); }
    }

    public string EntityName
    {
        get
        {
            return lblEntityName.Text;
        }
        set
        {
            lblEntityName.Text = value;
            lnkEntityName.Text = value;
        }
    }

    #endregion

    #region IManagedEntityName Members


    public string PreceedingText
    {
        get
        {
            return lblPreceedingText.Text;
        }
        set
        {
            lblPreceedingText.Text = value;
        }
    }

    public string PreceedingTextCss
    {
        get
        {
           return lblPreceedingText.CssClass;
        }
        set
        {
            lblPreceedingText.CssClass = value;
        }
    }

    public string EntityNameCss
    {
        get
        {
            return lblEntityName.CssClass;
        }
        set
        {
            lblEntityName.CssClass = value;
            lnkEntityName.CssClass = value;
        }
    }

    public bool ShowEntityURL
    {
        get
        {
            return lnkEntityName.Visible;
        }
        set
        {
            lnkEntityName.Visible = value;
            lblEntityName.Visible = !value;
        }
    }

    private EntityNameType _EntityType = EntityNameType.None;
    public EntityNameType EntityType
    {
        get { return _EntityType; }
        set { _EntityType = value; }
    }

    #endregion
    protected void lnkEntityName_Click(object sender, EventArgs e)
    {
        _ManagedEntityNameController.OpenEntityAdministrationView(EntityID, _EntityType);
    }
}
